package com.yjhb.android.sbz.adapter

import android.content.Context
import android.view.View
import android.widget.TextView
import com.bumptech.glide.Glide
import com.yjhb.android.sbz.R
import com.yjhb.android.sbz.entity.CheckResult
import com.yjhb.android.sbz.enums.TaskStatus
import com.jojo.android.zxlib.base.BaseRecyclerAdapterV2
import com.jojo.android.zxlib.tool.ZxTimeTool


/**
 *  创建者 zx
 *  创建时间 2021/3/23 14:13
 */
class RunningTaskUserAdapter(context: Context) : BaseRecyclerAdapterV2<BaseRecyclerAdapterV2.BaseHolder, CheckResult>(context) {


    override fun getLayoutId() = R.layout.item_running_task_user
    override fun getHolder(v: View) = BaseHolder(v)


    override fun onBindViewHolder(holder: BaseHolder, position: Int) {
        val checkResult = data[position]
        Glide.with(context).load(checkResult.avatar)
                .into(holder.findViewById(R.id.head_iv))
        holder.findViewById<TextView>(R.id.name_tv).text = checkResult.nickName
        holder.findViewById<TextView>(R.id.time_tv).text =
                ZxTimeTool.getDate(checkResult.taskOrder.fetchDateTime.time,"yyyy年MM月dd日 HH:mm")
        val stateTv = holder.findViewById<TextView>(R.id.state_tv)
        when (TaskStatus.getStatus(checkResult.taskOrder.state)) {
            TaskStatus.TASK_STATUS_TAKE -> stateTv.text = "进行中"
            TaskStatus.TASK_STATUS_TIMEOUT -> stateTv.text = "已超时"
            else -> stateTv.text = "其他状态"
        }
    }


}